package org.grottarossa.ui.core.casemanagement.discussions;

import com.vaadin.data.Item;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.TextField;

public  class DiscussionFormFactory extends DefaultFieldFactory {
	/**
	 *
	 */
	private static final long serialVersionUID = 2699103052135068432L;
	int parameter;
	public DiscussionFormFactory(int par) {
		this.parameter= par;
	}

	public Field createField(Item item, Object propertyId, Component uiContext) {
		Field f = super.createField(item, propertyId, uiContext);
		if ("name".equals(propertyId)) {
            TextField tf = (TextField) f;
            tf.setWidth("15em");
            if(parameter == 1 || parameter == 2){
            	tf.setEnabled(false);
            }

        } else if ("body".equals(propertyId)) {
            TextField tf = (TextField) f;
            tf.setWidth("20em");
            tf.setRows(5);
        }
		return f;
	}
}